package com.shoux.api.tools;


import com.shoux.api.enm.MsgEnum;
import com.shoux.api.web.entity.MsgEntity;

/**
 * @author SA
 * @version 1.0
 * @ClassName MsgUtils.java
 * @Description
 * @createTime 2021年05月14日 14:06:00
 */
public class MsgUtils {

    /**
     * 简单错误消息
     */
    private static MsgEntity simpleError;

    /**
     * 简单成功消息
     */
    private static MsgEntity simpleSuccess;


    static{
        simpleError = new MsgEntity(false, MsgEnum.SIMPLEFAIL.toString());
        simpleSuccess = new MsgEntity(true,MsgEnum.SIMPLESUCCESS.toString());
    }

    public static MsgEntity getSimpleErrorMsg(){
        return simpleError;
    }

    public static MsgEntity getSimpleSuccessMsg(){
        return simpleSuccess;
    }

    public static MsgEntity getMsg(Boolean status,String msg){
        return new MsgEntity(status,msg);
    }
    public static MsgEntity errorWhithMsg(String msg){
        return new MsgEntity(false, MsgEnum.SIMPLEFAIL.getCode(),msg,null);
    }
    public static MsgEntity success(int type){
        if(type<1){
            return new MsgEntity(false,MsgEnum.SIMPLEFAIL.getCode(),MsgEnum.SIMPLEFAIL.getDesc(),null);
        }else {
            return new MsgEntity(true, MsgEnum.SIMPLESUCCESS.getCode(),MsgEnum.SIMPLESUCCESS.getDesc(),null);
        }
    }
    public static MsgEntity successWhithData(Object data){
        return new MsgEntity(true,MsgEnum.SIMPLESUCCESS.getCode(),MsgEnum.SIMPLESUCCESS.getDesc(),data);
    }
    public static MsgEntity getMsg(Boolean status,Object data){
        return new MsgEntity(status,data);
    }

    public static MsgEntity getMsg(Boolean status,String code,String msg){
        return new MsgEntity(status,code,msg);
    }

    public static MsgEntity getMsg(Boolean status,String code,String msg,Object data){
        return new MsgEntity(status,code,msg,data);
    }

}
